﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Library.Models;
using Library.Repository;
using Library.Utils;
using ServiceHost1;
using log4net;
using log4net.Config;

namespace SerialisationToFileTest
{
    class Program
    {

        private static readonly ILog log = LogManager.GetLogger("Main");

        static void Main(string[] args)
        {
            log.Info("start... Linux? " + UserRepository.IsLinux);

            IUserRepository repository = ServiceLocator.Instance.GetService<IUserRepository>();
            IDeviceRepository deviceRepository = ServiceLocator.Instance.GetService<IDeviceRepository>();
            Console.ReadLine();

            //UserRepository.GenerateTestUsers();
            //DeviceRepository.GenerateTestDevices();

            ////TwiDevice device;
            ////device = deviceRepository.GetOrDie((char) 11);
            ////Console.WriteLine(device);

            ////device = new TwiDevice(){Address = (char) 37, Description = "Temperatura w kiblu", Type = (int)DeviceType.Temp};
            ////device = deviceRepository.Add(device);
            ////Console.WriteLine(device);


            //User user;
            ////user = repository.Add(new User() { Login = "Viewerbb", Name = "Podglądacz be-be", Pass = "123qwe", Role = (int)UserRole.Viewer });

            //user = repository.GetOrDie("Viewerbb");
            //Console.WriteLine(user);

            //repository.ChangeRole(user.Login, UserRole.Admin);

            //user = repository.GetOrDie("Viewerbb");
            //Console.WriteLine(user);

            //user = new User() { Login = "Admindd", Name = "Podglądacz de-de", Pass = "123qwe", Role = (int)UserRole.Admin };
            //user = repository.Add(user);

            //Console.WriteLine(repository.GetOrDie(user.Login));

            //repository.RemoveUser("Admindd");

            //Console.ReadLine();
        }
    }
}
